﻿using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

       
        private void button3_Click(object sender, EventArgs e)
        {
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string file1Path = textBox1.Text;
            string file2Path = textBox2.Text;

            if (!File.Exists(file1Path) || !File.Exists(file2Path))
            {
                MessageBox.Show("请选择两个存在的文件");
                return;
            }

            string mergedFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data", "merged.txt");

            using (StreamWriter writer = new StreamWriter(mergedFilePath))
            {
                string file1Content = File.ReadAllText(file1Path);
                writer.Write(file1Content);

                string file2Content = File.ReadAllText(file2Path);
                writer.Write(file2Content);
            }

            MessageBox.Show($"文件已合并并保存到{mergedFilePath}");
        }

        private void button3_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                textBox2.Text = openFileDialog.FileName;
            }
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = openFileDialog.FileName;
            }
        }
    }
}
